<?php
require_once 'config.php'; 
require_once 'Tools.class.php'; 
require_once 'HTML.class.php'; 
class BossMail{
    function getWebMailList($p,$opid){
        $p = max(1, (int)$p);
        $code = Tools::getHttp(DZU_URL."mail_list.asp?p=".$p);
        $code = trim($code);
        $cjb = explode("@MAILLIST",$code);
        for($i=1;count($cjb)>$i;$i++){
            $topic = Tools::getInfo($cjb[$i],"TOPIC");
            $id = Tools::getInfo($cjb[$i],"ID");
            $name = Tools::getInfo($cjb[$i],"NAME");
            $date = Tools::getInfo($cjb[$i],"DATE");
            $flag=Tools::getInfo($cjb[$i],"FLAG");
            if($flag=='mail3'){
                $image='mail.png';
            }else{
                $image='news.png';
            }
            $str .= HTML::makeList2($image,$topic,$name.'  '.$date,API_URL."weixin/web/index.php?action=mailbody&opid=".$opid."&id=".$id);
        }
        
        if($str==''){
            $str=HTML::makeListNULL("暂无邮件");
        }else{
            $str.=HTML::makeFooterButton(API_URL."weixin/web/index.php?action=maillist&opid=".$opid."&p=".($p+1),"下一页");
        }
        $tpl=file_get_contents(API_URL."weixin/web/list.html");
        $tpl=str_replace("_FORM", "", $tpl);
        $tpl=str_replace("_TITLE", '领导邮箱', $tpl);
        $tpl=str_replace("_LIST", $str, $tpl);
        return $tpl;
    }

    function getWebMail($id,$opid){
        $code = Tools::getHttp(DZU_URL."mail_body.asp?id=".$id);
        $code = trim($code);
        $mail = explode("@MAIL",$code);

        $id = Tools::getInfo($mail[1],"ID");
        $name = Tools::getInfo($mail[1],"NAME");
        $email = Tools::getInfo($mail[1],"EMAIL");
        $shouji = Tools::getInfo($mail[1],"SHOUJI");
        $tel=Tools::getInfo($mail[1],"TEL");
        $topic = Tools::getInfo($mail[1],"TOPIC");
        $content = Tools::getInfo($mail[1],"CONTENT");
        $reply = Tools::getInfo($mail[1],"REPLY");
        $ip = Tools::getInfo($mail[1],"IP");
        $date = Tools::getInfo($mail[1],"DATE");

        $str.= HTML::makeList3("姓名",$name);
        $str.= HTML::makeList3("邮箱",$email);
        $str.= HTML::makeList3("手机",$shouji);
        $str.= HTML::makeList3("电话",$tel);
        $str.= HTML::makeList3("日期",$date);
        $str.= HTML::makeList3("IP",$ip);
        $str.= HTML::makeList3("主题",$topic);
        $str.= HTML::makeList4("内容",$content);
        $str.= HTML::makeList4("回复",$reply);

        $tpl=file_get_contents(API_URL."weixin/web/mail.html");
        $tpl=str_replace("_TITLE", '邮件内容', $tpl);
        $tpl=str_replace("_LIST", $str, $tpl);
        return $tpl;
    }

}
?>